package win.zxshuo.www.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import win.zxshuo.www.controller.responses.BaseResponse;
import win.zxshuo.www.exception.BaseException;

@RestControllerAdvice
public class ExceptionController {

    private Logger logger = LoggerFactory.getLogger(getClass());


    @ExceptionHandler({ Exception.class })
    public BaseResponse exception(Exception e) {
        logger.error(e.getMessage(),e);
        return BaseResponse.getFailedResponseWithException(e);
    }

    @ExceptionHandler({BaseException.class})
    public BaseResponse exception(BaseException e){
        logger.error(e.getMessage(),e);
        return BaseResponse.getFailedResponseWithBaseException(e);
    }




}
